// const publicMethod = {
//     getTimestamp(time) { //把时间日期转成时间戳
//         return (new Date(time)).getTime() / 1000
//     }

// }

// formatDate(newDate) {
//     var year = now.getYear();
//     var month = now.getMonth() + 1;
//     var date = now.getDate();
//     var hour = now.getHours();
//     var minute = now.getMinutes();
//     var second = now.getSeconds();
//     return newDate = year + "-" + month + "-" + date + "   " + hour + ":" + minute + ":" + second;
// },
// const publicMethod = {
//     getLocalTime(nS) {
//         return newDate(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, ":");
//     }
// }
var getTime = function(stamp, way) {
    var data = new Date(stamp * 1000);
    var Y = data.getFullYear(); //获取传入时间戳的年
    var M = data.getMonth() + 1 //获取月份
    var D = data.getDate() //获取当前天
    var H = data.getHours() //小时
    var m = data.getMinutes() //分钟
    var s = data.getSeconds() //秒
    way = way.indexOf('Y') > -1 ? way.replace('Y', Y) : way;
    way = way.indexOf('M') > -1 ? way.replace('M', M) : way;
    way = way.indexOf('D') > -1 ? way.replace('D', D) : way;
    way = way.indexOf('H') > -1 ? way.replace('H', H) : way;
    way = way.indexOf('m') > -1 ? way.replace('m', m) : way;
    way = way.indexOf('s') > -1 ? way.replace('s', s) : way;
    console.log(way)
        //使用替换检查字符串是否具有该元素，有了替换
}
export default getTime